<template>
	<view class="page">

		<view class="cont-block-head">
			<block v-for="(item,index) in headList">
				<view class="cont-list-head" :class="headCurrentTab == index ? 'headListActive' : ''" :data-id="index" @tap="headTab">
					<view class="newstabBar" :class="headCurrentTab==index?'listActiveWhite':'listActiveWhite'">
						<text v-if="item.index==0">工友</text>
						<text v-if="item.index==1">空闲</text>
						<text v-if="item.index==2">商家</text>
						<text>{{item.name}}</text>
					</view>

				</view>
			</block>
		</view>

		<view class="page__bd">

			<view class="weui-tab" v-if="headCurrentTab == 0">

				<view class="cont-block">
					<block v-for="(item,index) in itemList">
						<view class="cont-list" :class="currentTab == index ? 'listActive' : ''" :id="index" @tap="tabClick">
							<image v-if="currentTab == index" mode='scaleToFill' :src="item.imgCheck"></image>
							<image v-else :src="item.img" mode='scaleToFill'></image>
							<text>{{item.name}}</text>
						</view>
					</block>
				</view>

				<view class="weui-tab__panel padd60">

					<view class="weui-tab__content" v-if="currentTab == 0 || currentTab == 1 || currentTab == 2 || currentTab == 3">
						<view class='order-item-wrap'>
							<view class='order-item dp-flex-col' v-for="(item,index) in lists" :id="item.id" @tap='orderDetailTap'>

								<form report-submit='true' @submit='onSubmit'>
									<button form-type='submit' class='btn-id'>
										<view class='order-item-top dp-flex-col'>
											<view class='order-item-demand-wrap dp-flex-between'>
												<view class='order-item-demand-type pb-5'>
													<text class='order-item-demand-title'>{{item.workProvince.name}}{{item.workCity.name}}{{item.workDistrict.name}}</text>
													<text class='order-item-demand-name'>{{item.work_description}}</text>

												</view>
												<view class='order-item-demand-moneny' v-if="item.type==1">
													<text v-if="item.day_money == '0.00'">电话沟通</text> <text v-else>￥{{item.day_money}}/天</text>
												</view>
											</view>

										</view>

										<view class='order-item-bottom'>
											<view class='order-item-detail-wrap dp-flex-col'>

												<view class='order-item-detail-total pb-5' v-if="item.type != 2">预计工期：{{item.work_day}}天</view>
												<view class='order-item-detail-people pb-5' v-if="item.type == 1">需求人数：{{item.need_amount}}人</view>
												<view class='order-item-detail-people pb-5' v-if="item.birthPlace">需求籍贯：{{item.birthPlace}}</view>
												<view class='order-item-detail-info dp-flex-between'>
													<view>发布时间：{{item.created_at}}</view>
													<view class='order-item-detail-view'>{{item.page_views}}人浏览</view>
												</view>
											</view>
										</view>

										<view class='order-status' v-if="item.status == 1">
											<view class='order-status-text'>已发布</view>
										</view>
										<view class='order-status' v-if="item.status == 3">
											<view class='order-status-text'>已完成</view>
										</view>
										<view class='order-status' v-if="item.status == 4">
											<view class='order-status-text'>已结束</view>
										</view>

									</button>
								</form>
							</view>
						</view>
					</view>


					<view class="weui-tab__content" v-if="currentTab == 4">
						<view class='tab-content'>
							<view class='order-item-wrap'>
								<block v-for="(item,index) in lists">
									<view class='order-item dp-flex-col' :id="item.work_order_id" data-type='31' @tap='orderDetailTap'>
										<form report-submit='true' @submit='onSubmit'>
											<button form-type='submit' class='btn-id'>
												<view class='order-item-top dp-flex-col'>

													<text class='order-item-demand-title'>{{item.workProvince.name}}{{item.workCity.name}}{{item.workDistrict.name}}</text>
													<text class='order-item-demand-name'>{{item.work_description}}</text>
												</view>

												<view class='order-item-bottom'>
													<view class='order-item-detail-wrap dp-flex-col'>

														<view class='order-item-detail-people pb-5' v-if="item.type == 1">需求人数：{{item.workOrder.need_amount}}人</view>
														<view class='order-item-detail-info dp-flex-between'>
															<view>发布时间：{{item.workOrder.created_at}}</view>
															<view class='order-item-detail-view'>{{item.workOrder.page_views}}人浏览</view>
														</view>
													</view>
												</view>


												<view class='order-status' v-if="item.workOrder.status == 1">
													<view class='order-status-text'>已发布</view>
												</view>
												<view class='order-status' v-if="item.workOrder.status == 3">
													<view class='order-status-text'>已完成</view>
												</view>
												<view class='order-status' v-if="item.workOrder.status == 4">
													<view class='order-status-text'>已结束</view>
												</view>

											</button>
										</form>
									</view>
									<view class='end-list'>
										<button class='end-order' open-type='contact' style='margin-right:auto;' :data-id="item.id">
											<image src='http://aliyun.oss.zxgyzj.com/picture/wx_red.jpg'></image>虚假信息投诉
										</button>
										<view class='end-order' :data-id="item.id" @tap='billEndOrder'>申请结束订单<image src='http://aliyun.oss.zxgyzj.com/picture/end-order.jpg'></image>
										</view>
									</view>
								</block>
							</view>
						</view>
					</view>


					<view class="weui-tab__content" v-if="currentTab == 5">
						<view class='tab-content'>
							<view class='order-item-wrap'>
								<block v-for="(item,index) in lists">
									<view class='order-item dp-flex-col' @tap='orderDetailTap'>
										<form report-submit='true' :id="item.id" @submit='onSubmit'>
											<button form-type='submit' class='btn-id' hover-stop-propagation='true'>
												<view class='order-item-top dp-flex-col'>
													<view class='order-item-demand-wrap dp-flex-between'>
														<view class='order-item-demand-type pb-5'>
															<text class='order-item-demand-title'>{{item.workProvince.name}}{{item.workCity.name}}{{item.workDistrict.name}}</text>
															<text class='order-item-demand-name'>{{item.work_description}}</text>
														</view>
														<view class='order-item-demand-moneny' v-if="item.type == 1">
															<text v-if="item.day_money == '0.00'">电话沟通</text> <text wx:else>￥{{item.day_money}}/天</text>
														</view>
														<view class='order-item-demand-moneny' v-else-if="item.type == 2">包工</view>
														<view class='order-item-demand-moneny' v-else-if="item.type == 3">施工队</view>
													</view>
													<view class='order-item-demand-addr'>{{item.address}}</view>
												</view>
												<view class='order-item-bottom'>
													<view class='order-item-detail-wrap dp-flex-col'>
														<view class='order-item-detail-date pb-5'>开工日期：{{item.start_time}}</view>
														<view class='order-item-detail-total pb-5' v-if="item.type != 2">预计工期：{{item.work_day}}天</view>
														<view class='order-item-detail-people pb-5' v-if="item.type == 1">需求人数：{{item.need_amount}}人</view>
														<view class='order-item-detail-info dp-flex-between'>
															<view>发布时间：{{item.created_at}}</view>
															<view class='order-item-detail-view'>{{item.page_views}}人浏览</view>
														</view>
													</view>
												</view>

												<view class='order-status' v-if="item.status == 1">
													<view class='order-status-text'>已发布</view>
												</view>
												<view class='order-status' v-if="item.status == 3">
													<view class='order-status-text'>已完成</view>
												</view>
												<view class='order-status' v-if="item.status == 4">
													<view class='order-status-text'>已结束</view>
												</view>

											</button>
										</form>
									</view>
									<view class='dial' v-for="(item,index) in item.orderPersonAll" wx:key="index">
										<view class='dial-list' :data-id="item.id" @tap='goCard'>
											<image class='dial-list-img' :src="item.avatarUrl"></image>
											<text style='margin-right:auto;font-weight: 600;'>{{item.name}}</text>
											<text style='font-size:26upx;'>{{item.created_at}}</text>
										</view>
									</view>
									<view class='end-list'>
										<view class='' style='margin-right:auto;' :data-id="item.id" @tap=''></view>
										<view class='end-order' :data-id="item.id" @tap='billEndOrder'>提前结束订单 <image src='http://aliyun.oss.zxgyzj.com/picture/end-order.jpg'></image>
										</view>
									</view>
								</block>

							</view>
						</view>
					</view>

				</view>

			</view>



			<view class="weui-tab-qz" v-if="headCurrentTab == 1">



				<view class='fixed-top-cont-shai'>
					<view class='fixed-top-container-shai' v-if="currentTab==0">
						<form report-submit='true' @submit='onSubmit'>
							<view class='fixed-top-shai'>
								<view class='fixed-top-left-shai dp-flex-y-center-shai'>
									<button class='fixed-cat-shai fixed-item-shai dp-flex-y-center-shai' form-type='submit' @tap='onTimeType'>
										时间排序
									</button>
									<button class='fixed-cat-shai fixed-item-shai dp-flex-y-center-shai' form-type='submit' @tap='onDistanceType'>
										距离排序
									</button>
									<button class='fixed-birthPlace-shai fixed-item-shai dp-flex-y-center-shai' form-type='submit' @tap='onDistrictType'>
										{{birthPlaceName ? birthPlaceName : "地区筛选"}}
									</button>
									<button class='fixed-cat-shai fixed-item-shai dp-flex-y-center-shai' form-type='submit' @tap='onAllType'>
										全选
									</button>
								</view>

							</view>
						</form>
					</view>
				</view>

				<view class="weui-tab__content">
					<view class='order-item-wrap'>

						<view class='order-item-qz dp-flex-col' v-for="(item,index) in second_lists" wx:key="item.id" :id="item.id" @tap='orderJobDetailTap'
						 data-useid="item.user.id">

							<view class='card-qz-box'>


								<view class='card-qr'>

									<image class='address-card-wx' :data-id="item.id" :data-name="item.user.address" src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/tab_my/card-wx.png'></image>
									<view class='card-block'>
										<view class='card-block-head' @tap='orderJobDetailTap' :data-id="item.id" :data-useid="item.user.id" id="item.id">
											<view class='card-block-head-top'>
												<image v-if="item.user.newAvatarUrl" class='block-head-img' :src="item.user.newAvatarUrl"></image>
												<image v-else class='block-head-img' src="item.user.avatarUrl ? item.user.avatarUrl : defaultAvatar"></image>
												<view class='block-head-user'>
													<view class='block-head-user-name'>
														<view class='block-head-user-name-title'>{{item.user.nickName}}</view>

														<view class='user-level-img'>
															<text class='user-level-text-mobile' style='color:black'>{{item.user.mobile}}</text>
														</view>
													</view>
													<view class='block-head-user-workCategory'>
														<text v-if="item.user.work_category_id">{{item.user.work_category_id}}</text>
														<text v-if="item.user.secondary_work_category_id">{{item.user.secondary_work_category_id}}</text>
													</view>
												</view>
											</view>
											<view class='card-block-head-address'>
												<image class='address-card-host' mode='scaleToFill' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/small_img/weizhi.png'></image>
												<text class='address-card-name'>{{item.address}}</text>
											</view>
										</view>
									</view>
								</view>


								<view class='order-item-qza dp-flex-col'>

									<form report-submit='true' @submit='onSubmit'>
										<button form-type='submit' class='btn-id-qz'>
											<view class='order-item-top-qz dp-flex-col'>
												<view class='order-item-demand-wrap dp-flex-between'>


												</view>
												<view class='order-item-demand-addr-jl'>
													<text>标题: {{item.title}}</text>
													<text>距离: {{item.user.address}}KM</text>
												</view>

											</view>

											<view class='order-item-bottom'>
												<view class='order-item-detail-wrap dp-flex-col'>
													<view class='order-item-detail-date pb-5'>{{item.description}}</view>

													<view class='order-item-detail-info dp-flex-between'>
														<view>发布时间：{{item.created_at}}</view>
														<view class='order-item-detail-view'>{{item.page_views}}人浏览</view>
													</view>
												</view>
											</view>

										</button>
									</form>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>



			<view class="weui-tab-qz" v-if="headCurrentTab == 2">

				<view class="weui-tab__panel padd60">

					<view class="weui-tab__content">
						<view class='order-item-wrap'>
							<view class='order-item dp-flex-col' v-for="(item,index) in lists" wx:key="item.id" :id="item.id" @tap='orderDetailTap'>
								<form report-submit='true' @submit='onSubmit'>
									<button form-type='submit' class='btn-id'>
										<view class='order-item-top dp-flex-col'>
											<view class='order-item-demand-wrap dp-flex-between'>
												<view class='order-item-demand-type pb-5'>
													<text class='order-item-demand-title' v-if="item.title">{{item.title}}</text>
													<text class='order-item-demand-name' v-if="item.workCategory.name">{{item.workCategory.name}}</text>
												</view>
											</view>
											<view class='order-item-demand-addr'>{{item.address}}</view>
										</view>

										<view class='order-item-bottom'>
											<view class='order-item-detail-wrap dp-flex-col'>
												<view class='order-item-detail-info dp-flex-between'>
													<view>发布时间：{{item.created_at}}</view>
													<view class='order-item-detail-view'>{{item.page_views}}人浏览</view>
												</view>
											</view>
										</view>

										<view class='order-status' v-if="item.status == 2">
											<view class='order-status-text'>已招满</view>
										</view>
										<view class='order-status' v-if="item.status == 3 || item.status == 4 || item.status == 6">
											<view class='order-status-text'>已结束</view>
										</view>

									</button>
								</form>
							</view>
						</view>
					</view>

				</view>

			</view>

			<view class='center_bar' @tap='goSend'>
				<image src='/static/images/job-want/relative2.png'></image>
			</view>
		</view>
	</view>

</template>

<script>
	import app from '@/App.vue';
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js'
	export default {
		onLoad: function(options) {
			var arr = this.main_getGlobal();
			console.log('onLoad开始的执行');
			this.getOrderRecord(arr.type, 0, 0, 1, arr.token);
		},
		/*onshow显示,只会显示一次*/
		/*生命周期函数--监听页面显示*/
		onShow: function() {
			// let userInfo = app.globalData.userInfo;
			// this.userInfo = app.globalData.userInfo;
			// this.notFirstTime = false;
			// if (app.globalData.userInfo.type == 1) {
			// 	console.log('onload为1的执行');
			// 	gyzjModel.prototype.showUserModal('../vip-info/vip-info');
			// } else {
			// 	console.log('onload不为1的执行');
			// 	if (!app.globalData.userInfo.nativeProvince) {
			// 		var second = 1;
			// 		this.interval = setInterval(function() {
			// 			second++;
			// 			if (second > 60) {
			// 				clearInterval(this.interval);
			// 				gyzjModel.prototype.identityInformation('../user-center/my-info/my-info');
			// 			}
			// 		}.bind(this), 1000);
			// 	}
			// }
		},
		/*页面上拉触底事件的处理函数*/
		onReachBottom: function() {
			let page = this.page;
			let pageCount = this.pageCount;
			const mainCat = this.mainCat;
			const subCat = this.subCat;
			// const token = app.globalData.token;
			let arr = this.main_getGlobal();
			if (this.currentTab == '1' || this.currentTab == '2' || this.currentTab == '4') return;
			if (this.headCurrentTab == '0') {
				console.log('执行了上拉刷新1');
				if (page < pageCount) {
					console.log('执行了上拉刷新11');
					page++;
					this.page = page;
					console.log('继续上拉刷新的值');
					console.log('继续上拉刷新的值', arr.type);
					console.log('继续上拉刷新的值', mainCat);
					console.log('继续上拉刷新的值', subCat);
					console.log('继续上拉刷新的值', page);
					console.log('继续上拉刷新的值', arr.token);
					/*最后一个参数不能设置为true,而是1*/
					this.getOrderRecord(arr.type, mainCat, subCat, page, arr.token, 1);
				} else {
					console.log('执行了上拉刷新12');
					uni.showToast({
						title: '没有更多数据了~',
						icon: 'none',
					})
				}
			} else {
				console.log('执行了上拉刷新2');
				/*当前页小于总页数*/
				if (page < pageCount) {
					console.log('执行了上拉刷新21');
					page++;
					this.page = page;
					this.getOrderRecord(arr.type, 0, 0, page, arr.token, true, 2);
				} else {
					console.log('执行了上拉刷新22');
					uni.showToast({
						title: '没有更多数据了~',
						icon: 'none',
					})
				}
			}

		},
		//下拉刷新
		onPullDownRefresh: function() {
			console.log('执行了刷新');
			var arr = this.main_getGlobal();
			var id = this.currentTab;
			var navId = this.headCurrentTab;
			switch (id) {
				case '0':
					this.getOrderRecord(arr.type, 0, 0, 1, arr.token);
					this.mainCat = 0;
					this.subCat = 0;
					break;
				case '1':
					this.getRegionOrder(this.itemList[1].name, 1);
					break;
				case '2':
					this.getRegionOrder(this.itemList[2].name, 2);
					break;
				case '3':
					this.getOrderRecord(arr.type, 1, 0, 1, arr.token);
					this.mainCat = 1;
					this.subCat = 0;
					break;
				case '4':
					this.getContactedOrder();

					this.worksActIndex = 0;
					this.mainCat = 2;
					this.subCat = 5;
					break;
				case '5':
					this.getOrderRecord(arr.type, 3, 1, 1, arr.token);
					this.pubActIndex = 0;
					this.pubText = "已发布";
					this.mainCat = 3;
					this.subCat = 1;
					break;
				default:
					break;
			}
			//如果刷新了求职信息,地区清空
			if (navId == 1) {
				this.getJobWantList(1, arr.token, 0, 0, arr.type);
				this.birthPlaceName = '地区筛选';
				this.native_district_id = '';
			}
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 300);
		},

		methods: {
			
			//提示入驻
			showUserModal: function() {
				this.isShowUserModal = true;
			},
			//全选排序
			onAllType: function() {
				console.log('时间排序');
				let arr = this.main_getGlobal();
				this.getJobWantList(1, arr.token, 0, 0, arr.type);
				this.birthPlaceName = '地区筛选';
				this.native_district_id = '';
			},
			//时间排序
			onTimeType: function() {
				console.log('时间排序');
				let arr = this.main_getGlobal();
				if (this.native_district_id) {
					console.log('既时间又地区');
					this.getJobWantList(1, arr.token, 1, this.native_district_id, arr.type);
				} else {
					console.log('只有时间的排序');
					this.getJobWantList(1, arr.token, 1, 0, arr.type);
				}
			},
			//筛选排序，外包改
			onDistanceType: function() {
				console.log('距离排序');
				let arr = this.main_getGlobal();
				this.getJobWantList(1, arr.token, 0, 0, arr.type);
			},
			//地区排序
			onDistrictType: function() {
				console.log('点击距离的筛选');
				let arr = this.main_getGlobal();
				uni.navigateTo({
					url: '../city-choose/city-choose?pageType=JobListBirth',
				})
				//this.getJobWantList(1, token, 1, 0);
				console.log('点击筛选时间');
			},
			// 筛选
			JobDistrictFilter: function() {
				let native_district_id = this.native_district_id;
				let arr = this.main_getGlobal();
				//这里type必须为1才会执行
				this.getJobWantList(1, arr.token, 0, native_district_id, arr.type);
				console.log('筛选的值', native_district_id);
			},
			/*发布订单*/
			goSend: function() {
				uni.navigateTo({
					url: '../order-release/order-release'
				})
			},
			//工作跳转到名片页面
			orderJobDetailTap: function(e) {
				const id = e.currentTarget.id;
				const useid = e.currentTarget.dataset.useid;
				console.log('我的id的值' + id);
				console.log('我的useid的值' + useid);
				uni.navigateTo({
					url: '../user-center/my-info/cardcase/cardcase?id=' + useid + '&jobId=' + id,
				})
			},
			// 获取二手闲置
			getJobWantList: function(type, token, time, district, loginType) {
				gyzjModel.prototype.getJobWantList(type, token, time, district, loginType).then(data => {
					switch (data.code) {
						case 1:
							let second_lists = this.second_lists;
							console.log(second_lists);
							// 处理订单数据
							var res = this.processData(data);
							console.log('res的值');
							console.log(res);
							console.log('lists的值');
							second_lists = res;
							console.log(second_lists);
							this.pageCount = data.data.page_count;
							if (second_lists.length != 0) {
								for (var i = 0; i < second_lists.length; i++) {
									console.log('地址分别是多少');
									console.log(second_lists[i].user.address);
									if (second_lists[i].user.address != 0) {
										console.log('执行成功了' + 1);
										second_lists[i].user.address = second_lists[i].user.address.slice(0, 3);
									} else {
										console.log('执行成功了' + 2);
										second_lists[i].user.address = 0;
									}

								}
							};
							this.second_lists = second_lists;
							break;
						default:
							wx.showToast({
								title: data.message,
								icon: 'none'
							});
							break;
					}
				});
			},
			
			// 跳转到订单详情
			orderDetailTap: function(e) {
				const mainCat = this.mainCat;
				const subCat = this.subCat;
				const id = e.currentTarget.id;
				// 承接进行中、承接已完成、承接已失效、发布已发布、发布施工中、发布已完成、发布已失效
				if (mainCat != 0 && subCat != 0) {
					cosole.log('1的详情');
					uni.navigateTo({
						url: 'order-detail/order-detail?id=' + id + '&mainCat=' + mainCat + '&subCat=' + subCat,
					})
					return;
				}
				uni.navigateTo({
					url: 'order-detail/order-detail?id=' + id,
				})
			},

			// onSubmit: function (e) {
			//   if (e.detail.formId) {
			//     const postData = {
			//       "formId": e.detail.formId
			//     }
			//     saveFormIdF(postData, app.globalData.token)
			//   }
			// },
			// 地区订单
			getRegionOrder: function(id, type) {
				console.log('选中省id', id);
				console.log('选中type', type);
				var postData = {
					id: id,
					type: type
				}
				gyzjModel.prototype.getOrderList(postData).then(data => {
					let code = data.code;
					switch (code) {
						case 1:
							var lists = data.data.data;
							console.log('lists的值', lists);
							console.log('page_count的值', data.data.page_count);
							this.pageCount = data.data.page_count;
							this.lists = lists;
							break;
						default:
							uni.showToast({
								title: data.message,
								icon: 'none'
							});
							break;
					}
				});
			},
			// 处理数据
			processData: function(data) {
				console.log('处理数据进来', data);
				let array = [];
				data.data.data.map((cur, index, arr) => {
					console.log('处理数据的province', cur['province']);
					console.log('处理数据的city', cur['city']);
					console.log('处理数据的district', cur['district']);
					console.log('处理数据的birthPlace', cur['birthPlace']);
					// 处理籍贯字段
					cur['birthPlace'] = '';
					if (cur['province']) cur['birthPlace'] += cur['province']['name'];
					if (cur['city']) cur['birthPlace'] += cur['city']['name'];
					if (cur['district']) cur['birthPlace'] += cur['district']['name'];
					array.push(cur);
				})
				console.log('处理数据的', array);
				return array;
			},
			// 获取订单记录
			getOrderRecord: function(loginType, type, userType, page, token, loadMore, is_business) {
				gyzjModel.prototype.getOrderRecord(loginType, type, userType, page, token, loadMore, is_business).then(data => {
					switch (data.code) {
						case 1:
							let lists = this.lists;
							// console.log('获取订单记录进来', lists);
							// 处理订单数据
							var res = this.processData(data);
							console.log('获取订单记录总的data', data);
							console.log('获取订单记录总的res', res);
							if (loadMore) {
								console.log('成功执行了loadMore');
								console.log('loadMore的res的值为', res);
								lists = lists.concat(res);
								console.log('lists的值为', lists);
							} else {
								console.log('没有执行loadMore');
								lists = res;
							}
							console.log('总页数的pageCount为', data.data.page_count);
							console.log('总页数的lists为', lists);
							this.pageCount = data.data.page_count;
							this.lists = lists;
							break;
						default:
							uni.showToast({
								title: data.message,
								icon: 'none'
							});
							break;
					}
				});
			
			},
			// 商家，工人订单
			headTab: function(e) {
				let arr = this.main_getGlobal();
				let id = e.currentTarget.dataset.id;
				console.log('id是多少' + id);

				if (id == '2') {
					
					this.getOrderRecord(arr.type,0, 0, 1, arr.token, false, 2);
				} else if (id == '0') {
					var curId = this.currentTabHead;
					console.log(curId)
					if (curId == '0') {
						console.log('執行了第0個');
						this.getOrderRecord(arr.type,0, 0, 1, arr.token);
						this.mainCat = 0;
						this.subCat = 0;
					} else if (curId == '1') {
						console.log('執行了第1個');
						this.getRegionOrder(this.itemList[1].name, 1);
					} else if (curId == '2') {
						console.log('執行了第2個');
						this.getRegionOrder(this.itemList[2].name, 2);
					} else if (curId == '3') {
						console.log('執行了第3個');
						this.getOrderRecord(arr.type,1, 0, 1, arr.token);
						this.mainCat = 1;
						this.subCat = 0;
					} else if (curId == '4') {
						// this.getContactedOrder();
						this.worksActIndex = 0;
						this.mainCat = 2;
						this.subCat = 5;
					} else if (curId == '5') {
						// this.getOrderRecord(3, 1, 1, token);
						this.pubActIndex = 0;
						this.pubText = "已发布";
						this.mainCat = 3;
						this.subCat = 1;
					}
				} else if (id == '1') {
					console.log('我的磨');
					this.getJobWantList(1, arr.token, 0, 0, arr.type);

				}
				this.headCurrentTab = id;
			},
			// 地区订单
			getContactedOrder: function() {
				var arr = this.main_getGlobal();
				gyzjModel.prototype.getContactedList(arr.token, arr.type).then(data => {
					switch (data.code) {
						case 1:
							var lists = data.data.data;
							this.pageCount = data.data.page_count;
							this.lists = lists;
							break;
						default:
							uni.showToast({
								title: data.message,
								icon: 'none'
							});
							break;
					}
				});
			},
			// 总订单分类切换
			tabClick: function(e) {
				var arr = this.main_getGlobal();
				const id = e.currentTarget.id;
				this.sliderOffset = e.currentTarget.offsetLeft;
				this.activeIndex = e.currentTarget.id;
				this.currentTab = e.currentTarget.id;
				this.page = 1;
				console.log('執行的id的值',id);
				switch (id) {
					case '0':
						this.getOrderRecord(arr.type, 0, 0, 1, arr.token);
						this.mainCat = 0;
						this.subCat = 0;
						break;
					case '1':
						this.getRegionOrder(this.itemList[1].name, 1);
						break;
					case '2':
						this.getRegionOrder(this.itemList[2].name, 2);
						break;
					case '3':
						this.getOrderRecord(arr.type, 1, 0, 1, arr.token);
						this.mainCat = 1;
						this.subCat = 0;
						break;
					case '4':
						this.getContactedOrder();
						this.worksActIndex = 0;
						this.workerText = '待支付';
						this.pubText = '已计算';
						this.mainCat = 2;
						this.subCat = 5;
						break;
					case '5':
						console.log('已发布的');
						this.getOrderRecord(arr.type, 3, 1, 1, arr.token);
						this.pubActIndex = 0;
						this.mainCat = 3;
						this.subCat = 1;

						break;
					default:
						break;
				}
			},
		},
		data() {
			return {
				userInfo:'',
				second_lists: [

				],
				headList: [{
						name: '订单',

						index: 0
					},
					{
						name: '工友',
						index: 1
					},
					{
						name: '订单',
						index: 2
					},
				],
				headCurrentTab: 0,
				//地址需要用到
				native_district_id: '',
				birthPlaceName: "",
				itemList: [{
						name: '全部订单',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all-check.png',
						index: 0
					},
					{
						name: '湖南省',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all-check.png',
						index: 1
					},
					{
						name: '长沙市',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/all-check.png',
						index: 2
					},
					{
						name: '我感兴趣的',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/interest.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/interest-check.png',
						index: 3
					},
					{
						name: '我联系过的',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/relation.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/relation-check.png',
						index: 4
					},
					{
						name: '我发布的',
						img: 'http://aliyun.oss.zxgyzj.com/picture/order-list/issue.png',
						imgCheck: 'http://aliyun.oss.zxgyzj.com/picture/order-list/issue-check.png',
						index: 5
					},
				],
				currentTab: 0,
				currentTabHead: 0,

				tabs_radio: [{
						name: '所有',
						value: '所有',
						checked: 'ture'
					},
					{
						name: '我感兴趣的',
						value: '我感兴趣的'
					},
					{
						name: '我联系过的',
						value: '我联系过的'
					},
					{
						name: '我发布的',
						value: '我发布的'
					},
				],
				tabs: ["所有", "我感兴趣的", "我联系过的", "我发布的"],
				activeIndex: 0, // 总订单分类索引，默认显示所有
				worksActIndex: 0, // 承接的订单分类索引，默认显示待支付
				pubActIndex: 0, // 发布的订单分类索引，默认显示已发布
				sliderOffset: 0,
				sliderLeft: 0,

				// 列表记录
				lists: [],

				merchantLists: [],

				// 我承接的二级分类文本
				workerText: '',

				// 我发布的二级分类文本
				pubText: '',

				// 分页信息
				page: 1,
				pageCount: 1,

				// 选中栏目
				mainCat: 0,
				subCat: 0,

				interval: '', //定时器

				isShowUserModal: false,
			}

		}
	}
</script>

<style>
	page {
		background-color: #efeff4;
		font-size: 16px;
		font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif;
	}

	.center_bar,
	.center_bar image {
		position: fixed;
		width: 100upx;
		height: 100upx;
		right: 5%;
		bottom: 10%;
		z-index: 999;
	}

	.head-block {
		display: flex;
		height: 7vh;
		border-bottom: 1px solid #e5e5e5;
	}

	.head-list {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		border-right: 1px solid #e5e5e5;
		font-size: 32upx;
	}

	.head-list:nth-child(3) {
		border-right: none;
	}

	.head-list image {
		width: 20upx;
		height: 15upx;
		margin-left: 10upx
	}

	.headListActive {
		background-color: #f94c48 !important;
		border-bottom: 1px solid #f94c48 !important;
		color: #fff;
	}

	/* 订单列表 */
	.order-item-wrap {
		padding-top: 20upx;
	}

	.order-item {
		position: relative;
		margin: 20upx 30upx;
		padding: 20upx 30upx;
		background-color: #fff;
		color: #666;
		border-radius: 5px;
		/* box-shadow:0px 0px 10px 1px #ccc; */
		box-shadow: 0px 5px 10px 2px #999;
	}

	.order-item-top {
		position: relative;
		color: #333;
		padding-bottom: 10upx;
	}

	.order-item-top::after {
		content: " ";
		position: absolute;
		left: 0;
		right: -30upx;
		height: 1px;
		color: #e5e5e5;
		z-index: 2;
		bottom: 0;
		border-bottom: 1px solid #e5e5e5;
		/* -webkit-transform-origin: 0 100%;
	  transform-origin: 0 100%;
	  -webkit-transform: scaleY(.5);
	  transform: scaleY(.5); */
	}

	.order-item-demand-moneny {
		color: #F94C48;
	}

	.order-item-bottom {
		padding-top: 10upx;
		font-size: 14px;
	}

	.order-item-detail-view {
		/* color: #F94C48; */
	}

	.pb-5 {
		padding-bottom: 10upx;
	}

	.order-item-demand-name {
		padding-right: 20upx;
	}



	/* 我承接的订单 */
	.my-works-wrap,
	.my-publish-wrap {
		text-align: center;
		background-color: #fff;
		border-bottom: 1px solid #e5e5e5;
	}

	.works-tab,
	.publish-tab {
		padding: 20upx 0;
	}

	.active {
		color: #F94C48;
	}

	/* 订单状态 */
	.order-status {
		position: absolute;
		right: 20upx;
		top: 40%;
		color: #ccc;
		transform: rotate(-20deg);
	}

	.order-status-text {
		height: 150upx;
		width: 150upx;
		line-height: 150upx;
		text-align: center;
		font-size: 20px;
		border: 1px solid #ccc;
		border-radius: 50%;
	}

	.btn-id,
	.btn-id-qz {
		background: #fff;
		position: static;
		padding: 0;
		margin: 0;
		text-align: left;
		border-radius: 0;
		line-height: 46upx;
		font-size: 32upx;
	}

	/* 求职样式 */
	.btn-id-qz {
		margin-top: 10upx;
	}

	.btn-id .order-item-bottom {
		color: #666;
	}

	.header-tab {
		padding: 0;
		height: 120upx;
		line-height: 120upx;
		border-bottom: 1px solid #000000;
	}

	.weui-navbar__title {
		/* font-size: 32upx; */
		font-weight: 600;
	}

	.padd60 {
		padding-top: 20upx;
	}

	.cont-block {
		background-color: #fff;
		flex-wrap: wrap;
		display: flex;
		padding: 30upx;
	}

	.cont-list {
		width: 33%;
		height: 100upx;
		padding-top: 20upx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		font-size: 32upx;
		border-right: 1px solid #666;
	}

	.cont-list:nth-child(-n+3) {
		border-bottom: 1px solid #666;
	}

	.cont-list:nth-child(3n) {
		border-right: none;
	}

	.cont-list image {
		width: 40upx;
		height: 40upx;
		margin-bottom: 10upx;
	}

	.listActive {
		color: #f94c48;
	}

	.order-item-demand-title {
		/* display: inline-block; */
		margin-right: 10upx;
		display: flex;

	}

	.end-list {
		display: flex;
		padding: 0 30upx 20upx;
		/* margin-bottom: 20upx; */
		border-bottom: 1px solid #ccc;
	}

	.end-order {
		/* margin: 0 30upx 20upx 30upx; */
		width: 40%;
		height: 60upx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		border-radius: 10upx;
		font-size: 28upx;
		color: #666;
	}

	.end-order image {
		width: 31upx;
		height: 31upx;
		margin: 0 10upx;
	}

	button {
		padding: 0;
	}

	.dial {
		margin: 20upx 30upx;
		background-color: #fff;
		border-radius: 15upx;
	}

	.dial-list {
		display: flex;
		padding: 20upx;
		align-items: center;
	}

	.dial-list-img {
		width: 100upx;
		height: 100upx;
		border-radius: 50%;
		margin-right: 20upx;
	}

	button {
		margin-left: 0;
	}

	/* 新的导航条的开始 */
	/*新增加的二手闲置导航条*/
	.cont-block-head {
		display: flex;
		height: 10vh;
		border-bottom: 1px solid #e5e5e5;
	}

	.fixed-top-cont {
		width: 100%;
		background-color: #ebefed;
		display: flex;
		flex-direction: column;
		max-height: 20vh;
		min-height: 12vh;
		overflow: hidden;
	}

	/* .cont-list-head {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		border-right: 1px solid #e5e5e5;
		font-size: 36upx;
		background-color: #ffffcc;
	} */
	.cont-list-head {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		border-right: 1px solid #e5e5e5;
		font-size: 36upx;
		background-color: #ffffcc;
	}

	.cont-list-head:nth-child(3) {
		border-right: none;
	}

	.cont-list-head image {
		width: 20upx;
		height: 15upx;
		margin-left: 10upx
	}

	.cont-list-head text:nth-child(1) {
		display: block;
		width: 153upx;
		height: 30upx;
		margin-bottom: 10upx;
	}

	/*如果是最后一个样式存在冲突*/
	/* .cont-list-head:nth-child(4) text:nth-child(1){
	  line-height:100upx;
	} */
	.cont-list-head .newstabBar {
		text-align: center;
		height: 90upx;
		/* margin-top:-10upx; */
	}

	/* .cont-list-head:nth-child(1) .newstabBar{
	  border-bottom: 8upx solid white;
	} */
	.cont-list-head text:nth-child(2) {
		display: block;
		width: 153upx;
		height: 30upx;
	}

	.listActiveHead {
		background-color: #f94c48;
		color: #fff;
	}

	.listActiveWhite {
		border-bottom: 5upx solid white;
	}

	.cont-list .newstabBar {
		text-align: center;
		height: 90upx;
		/* margin-top:-10upx; */
	}

	/* 结束 */



	/*新增的名片样式*/
	.card {
		width: 100%;
		height: 395upx;
		position: relative;
	}

	.card-img {
		width: 100%;
		height: 400upx;
		z-index: -1;
	}

	.card-block {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 80%;
	}

	.block-head-img {
		width: 180upx;
		height: 180upx;
		border-radius: 50%;
		margin-right: 20upx;
	}

	.card-block-head {
		border-radius: 15upx;
		margin: 20upx 20upx 10upx 20upx;
		background-color: white;
		display: flex;
		padding: 10upx 20upx 20upx 25upx;
		flex-direction: column;

	}

	.card-block-head-top {
		display: flex;
		align-items: center;
		height: 230upx;
		width: 100%;
	}

	.block-head-user {
		width: 70%;
		color: #fff;
		margin-top: 30upx;

	}

	.block-head-user-name {
		width: 100%;
		display: flex;
		flex-direction: column;
		height: 110upx;
		font-size: 36upx;
		font-weight: 600;
	}

	/**/
	.block-head-user-name-title {
		max-width: 80%;
		font-size: 36upx;
		color: black;
		/* 超出部分隐藏 */
		overflow: hidden;
		/* 隐藏部分用...代替 */
		text-overflow: ellipsis;
		/* 一行显示，不自动换行 */
		white-space: nowrap;
		/* text-overflow: ellipsis; */
	}

	.user-level-img {
		display: inline-block;
	}

	.icon-star {
		width: 36upx;
		height: 36upx;
	}

	.card-block-head-address {
		height: 100upx;
		display: flex;
		align-items: flex-end;
		color: #fff;
		font-size: 32upx;
	}

	.address-card-name {
		width: 90%;
		margin-right: auto;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		line-height: 1;
		color: black;
	}

	.address-card-host {
		width: 36upx;
		height: 48upx;
		margin-right: 20upx;
	}

	.address-card-wx {
		position: absolute;
		top: 40upx;
		right: 50upx;
		width: 80upx;
		height: 80upx;
		z-index: 9;
	}

	.block-head-user-workCategory text {
		border: 1px solid #FFB02D;
		display: inline-block;
		padding: 2upx 20upx;
		margin: 18upx 20upx 10upx 0;
		border-radius: 15upx;
		color: black;
	}

	/* 个人简介 */
	.card-block-brief {
		margin: 0 20upx;
		padding-bottom: 20upx;
	}

	.card-block-brief-head {
		height: 60upx;
		margin: 10upx 0;
		display: flex;
		align-items: center;
		color: #FFB02D;
	}

	.card-block-brief-img {
		width: 30upx;
		height: 40upx;
		margin-right: 20upx;
	}

	.card-block-brief-intr {
		/* width: 100%; */
		margin: 20upx 20upx 0;
		/* padding-bottom: 20upx; */
		color: #FFB02D;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	/*名片下的分享和拨打电话*/
	.card-line-btn {
		padding: 20upx;
		padding-bottom: 0upx;
		display: flex;
	}

	.line-btn-editinfo {
		width: 35%;
		height: 80upx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 15upx;
		color: #fff;
		background-color: #666666;
		margin-right: 2%;

	}

	.line-btn-editinfo image {
		width: 40upx;
		height: 40upx;
		margin-right: 20upx;
	}

	.line-btn-card {
		width: 35%;
		height: 80upx;
		line-height: 80upx;
		padding: 0;
		border-radius: 15upx;
		background-color: #656565;
		display: flex;
		align-items: center;
		justify-content: center;
		color: white;
	}

	.line-btn-card image {
		width: 40upx;
		height: 40upx;
		margin-right: 20upx;
	}

	.line-btn-collect {
		width: 26%;
		height: 80upx;
		margin-right: 2%;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 15upx;
		background-color: #666666;
		color: white;
	}

	.line-btn-collect image {
		width: 32upx;
		height: 32upx;
		margin-right: 20upx;
	}

	/*名片结束页*/
	/*标题和距离的开始*/
	.order-item-demand-addr-jl {
		width: auto;
		float: left;
	}

	.order-item-demand-addr-jl text:nth-child(1) {

		margin-right: 30upx;
	}

	.order-item-demand-addr-jl text:nth-child(2) {
		float: right;

	}

	/*求职微调*/
	.card-qz-box {
		width: 94%;
		height: 100%;
		background: black;
		border-radius: 10upx;
		margin: 0 3%;
	}

	.order-item-qz {
		position: relative;
		margin: 0upx 0upx;
		padding: 0upx 0upx;
		/* background-color: #fff; */
		color: #DFDFE2;
		border-radius: 5px;
		box-shadow: 0px 0px 10px 1px #ccc;
		margin-bottom: 20upx;
		background-color: #E4E4E7;
	}

	.order-item-qza {
		position: relative;
		margin: 0upx 0upx;
		padding: 0upx 20upx;
		background-color: #fff;
		color: #666;
		border-radius: 0px;
		box-shadow: 0px 5px 10px 2px #999;
		margin-bottom: 3upx;
		border-bottom-left-radius: 10upx;
		border-bottom-right-radius: 10upx;

	}

	.card-qr {
		width: 100%;
		height: 395upx;
		position: relative;

	}

	/* .order-item-top-qz {
	  position: relative;
	  color: #333;
	  padding-bottom: 10upx;
	  padding:0upx 20upx;
	} */
	.weui-tab-qz {
		position: relative;
		height: 100%;
		border-top: 20upx solid white;
	}

	/* 分类筛选 */
	/* 分类筛选 */
	.fixed-top-container {
		width: 100%;
		background-color: #fff;
		height: 9vh;
		font-size: 14px;
	}

	.fixed-top {
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		height: 100%;
		align-items: center;
		/* border: 1px solid #e5e5e5; */
	}

	.fixed-top-left {
		display: flex;
		margin-left: 20upx;
	}

	.fixed-item {
		padding: 0upx 20upx;
		height: 68upx;
	}

	.fixed-item image {
		width: 56upx;
	}

	.fixed-cat,
	.fixed-birthPlace {
		border: 1px solid #666;
		/* color: #F94C48; */
		border-radius: 5px;
		margin-right: 20upx;
	}

	.fixed-bottom-content {
		border-top: 1px solid #e5e5e5;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 750upx;
		z-index: 999;
	}

	.is135 {
		bottom: 135upx;
	}

	.worker-detail-box {
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 20upx 30upx;
	}

	.photo {
		width: 88upx;
		height: 88upx;
		display: block;
	}

	.info-box {
		width: 350upx;
		overflow: hidden;
		/* margin-right: 20upx; */
	}

	.max-width-190 {
		max-width: 190upx;
	}

	.worker-type {
		/* max-width: 130upx; */
		margin: 0 10px;
		color: #c90000;
	}

	.right-box {
		width: 200upx;
		height: 60upx;
		flex: 1;
		border-radius: 5px;
		text-align: center;
		padding: 2upx 15upx;
		border: 1px solid #f94c48;
		background-color: #f94c48;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.right-box-check {
		display: inline-block;
	}

	.right-box-check-img {
		display: inline-block;
		width: 25upx;
		height: 20upx;
		/* margin-left: 10upx; */
	}

	.star-box {
		display: flex;
		margin-top: 2px;
	}

	.star-item {
		width: 30upx;
		height: 30upx;
		margin-right: 4upx;
	}

	.txt-gray {
		color: #999;
		font-size: 30upx;
	}

	/* 刷新图标和联系客服图标 */
	.refresh-wrap {
		width: 100upx;
		height: 68upx;
		box-sizing: border-box;
	}

	/*设置按钮的筛选*/
	button {
		position: relative;
		display: block;
		margin-left: auto;
		margin-right: auto;
		padding-left: 14px;
		padding-right: 14px;
		box-sizing: border-box;
		font-size: 18px;
		text-align: center;
		text-decoration: none;
		line-height: 2.55555556;
		border-radius: 5px;
		-webkit-tap-highlight-color: transparent;
		overflow: hidden;
		/* color: red; */
		/* background-color: black; */
	}

	.fixed-cat,
	.fixed-birthPlace {
		border: 1px solid #666;
		border-radius: 5px;
		margin-right: 20upx;
	}

	.fixed-item {
		padding: 0upx 20upx;
		height: 68upx;

	}

	.button-hover {
		/* color: red;
	background-color: blue; */
	}

	/*空闲工友的筛选重写开始*/
	.fixed-top-cont-shai {
		width: 100%;
		background-color: white;
		display: flex;
		flex-direction: column;
		max-height: 20vh;
		min-height: 12vh;
		overflow: hidden;
	}

	.fixed-top-container-shai {
		width: 100%;
		background-color: #fff;
		height: 9vh;
		font-size: 14px;
	}

	.fixed-top-shai {
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		height: 100%;
		align-items: center;
		/* border: 1px solid #e5e5e5; */
	}

	.fixed-top-left-shai {
		display: flex;
		margin-left: 20upx;
	}

	.fixed-cat-shai,
	.fixed-birthPlace-shai {
		border: 1px solid #666;
		/* color: #F94C48; */
		border-radius: 5px;
		margin-right: 20upx;
	}

	.fixed-item-shai {
		padding: 0upx 6upx;
		height: 68upx;
		margin-top: 16px;
		line-height: 68upx;
		font-size: 17px;
	}

	.dp-flex-between {
		display: flex;
		justify-content: space-between;

	}

	/*空闲工友的筛选重写结束*/
</style>
